//
//  NavViewStyleMyInterest.m
//  ZITHER
//
//  Created by weixin on 2018/11/15.
//  Copyright © 2018 weixn. All rights reserved.
//

#import "NavViewStyleMyInterest.h"

@implementation NavViewStyleMyInterest


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUI];
        if ([Main_Token_Model_MANAGER.isToken isEqualToString:@"1"]){
            self.backgroundColor =  Main_Token_Model_MANAGER.backgroundColor ;
        }
    }
    return self;
}

-(void)setUI{
    [self addSubview:self.leftBtn];
    [self addSubview:self.leftTitleBtn];
    [self addSubview:self.rightTitleBtn];
    [self addSubview:self.bottomLine];
    [self addSubview:self.viewBlcak];
}

-(BaseBtn *)leftBtn
{
    if (!_leftBtn) {
        _leftBtn = [[BaseBtn alloc]initializeFrame:CGRectMake(15, 0, 20, 40) NormalImage:@"common_back" SeleImage:@"common_back"];
        [self.leftBtn setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 20, 0)];//调整图片大小5:2
        _leftBtn.centerY = self.centerY+centerYH;
        @weakify(self);
        [[_leftBtn rac_signalForControlEvents:(UIControlEventTouchUpInside)] subscribeNext:^(__kindof UIControl * _Nullable x) {
            @strongify(self);
            [self.getNav popViewControllerAnimated:YES];
        }];
        _leftBtn.backgroundColor = [UIColor clearColor];
        
        [_leftBtn setLocalImage:@"common_back"];


    }
    return _leftBtn;
}


-(BaseView *)bottomLine
{
    if (!_bottomLine) {
        _bottomLine = [[BaseView alloc]initWithFrame:CGRectMake(0, self.frame.size.height-1, kScreenW,1)];
        [_bottomLine setShadowType1WithColor:[UIColor defaultShadowColor] offset:CGSizeMake(0, 5) opacity:1 radius:3];
    }
    return _bottomLine;
}

-(BaseBtn *)leftTitleBtn
{
    if (!_leftTitleBtn) {
        _leftTitleBtn = [[BaseBtn alloc]initializeFrame:CGRectMake(0, 0, 80, 30) NormalText:@"我的关注" NormalTextColor:[UIColor colorWithHex:@"333333"] SeleText:@"我关注的" SeleTextColor:[UIColor colorWithHex:@"333333"] font:14 isBold:NO];
        _leftTitleBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:14];
        _leftTitleBtn.centerY = self.centerY+centerYH;
        _leftTitleBtn.centerX = self.centerX-50;
        _leftTitleBtn.backgroundColor = [UIColor clearColor];
        if ([Main_Token_Model_MANAGER.isToken isEqualToString:@"1"]){
            [_leftTitleBtn setTitleColor:Main_Token_Model_MANAGER.navTitleColor forState:UIControlStateNormal];
        }else{
            [_leftTitleBtn setTitleColor:[UIColor colorWithHex:@"333333"] forState:UIControlStateNormal];
        }
        
    }
    return _leftTitleBtn;
}

-(BaseBtn *)rightTitleBtn
{
    if (!_rightTitleBtn) {
        _rightTitleBtn = [[BaseBtn alloc]initializeFrame:CGRectMake(0, 0,80, 30) NormalText:@"关注我的" NormalTextColor:[UIColor colorWithHex:@"333333"] SeleText:@"关注我的" SeleTextColor:[UIColor colorWithHex:@"333333"] font:14 isBold:NO];
        
        if ([Main_Token_Model_MANAGER.isToken isEqualToString:@"1"]){
            [_rightTitleBtn setTitleColor: Main_Token_Model_MANAGER.navTitleColor forState:UIControlStateNormal];
        }else{
            [_rightTitleBtn setTitleColor:[UIColor colorWithHex:@"333333"] forState:UIControlStateNormal];
        }
        _rightTitleBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:14];
        _rightTitleBtn.centerY = self.centerY+centerYH;
        _rightTitleBtn.centerX = self.centerX+50;
        _rightTitleBtn.backgroundColor = [UIColor clearColor];
    }
    return _rightTitleBtn;
}

-(UIView *)viewBlcak{
    if (!_viewBlcak) {
        CGFloat width = [NSString textWidth:@"我关注的" font:14 height:15];
        _viewBlcak = [[UIView alloc]initWithFrame:CGRectMake(self.leftTitleBtn.frame.origin.x+10, NaviHeight-2,width,2)];
        
        if ([Main_Token_Model_MANAGER.isToken isEqualToString:@"1"]){
            _viewBlcak.backgroundColor = Main_Token_Model_MANAGER.navTitleColor;
        }else{
            _viewBlcak.backgroundColor = [UIColor blackColor];
        }

    }
    return _viewBlcak;
}

@end
